var ACTION = require("../../base/action");
var utils = require("../../utils/utils");
var ocrGml = require("../../utils/ocrGml");
var common = require("./common");
var actionSleep30 = new ACTION("随机搜赚钱", {
  execSCount: 0,
  execFCount: 0,
  maxExecSCount: 30,
  maxExecFCount: 5,
  storage: common.storage,
});
actionSleep30.exec = function () {
  var ocrItem = ocrGml.findTextOne(
    ["随机搜赚钱"],
    true,
    null,
    1,
    device.height / 10
  );
  if (ocrItem) {
    var point = utils.getOcrItemPoint(ocrItem);
    var x = point.x;
    var y = point.y;
    for (var index = 0; index < 2; index++) {
      utils.clickXY(x, y);
      sleep(utils.getRandom(2, 3, 1000));
      var baseSpan = 15;
      var span = utils.getRandom(baseSpan, baseSpan + 5);
      common.readArticle(span, 5);
      back();
      sleep(utils.getRandom(2, 3, 1000));
      if (utils.clickTextStartsWith("残忍离开")) {
        console.log("actionSleep30", "找到-残忍离开-");
        sleep(utils.getRandom(2, 3, 1000));
      } else {
        console.log("actionSleep30", "没找到-残忍离开-");
      }
    }
    this.execSCount = this.execSCount + 2;
    this.updateStorage();
  } else {
    this.execFCount++;
    this.updateStorage();
  }
};

module.exports = actionSleep30;
